﻿using System.Collections.Generic;
using ProtoBuf;

namespace HNet
{
    [ProtoContract]
    public class Message
    {
        //发送者索引
        [ProtoMember(1)]
        public int Sender;

        //接收者索引，为0时仅发给服务器
        [ProtoMember(2)]
        public int[] Receiver;

        //几种除了发送为用户以外的接收者索引
        public const int ServerIndex = 0;

        public const int AllClients = -1;

        public const int OtherClients = -2;

        public enum MsgType
        {
            ServerState,//服务器状态（服务器心跳包）
            Heartbeat,//客户端心跳
            Remote,//远程调用
            MonoRemote,//对物体脚本的远程调用
            Other
        }

        [ProtoMember(3)]
        public MsgType Type;

        [ProtoMember(4)]
        public byte[] Data;

        [ProtoMember(5)]
        public List<byte[]> DataList;

        public Message()
        {
            DataList = new List<byte[]>();
        }
    }
}